package com.gxa.zhonglong.service.impl;

import com.gxa.zhonglong.common.ExceptionCode;
import com.gxa.zhonglong.exception.BusinessException;
import com.gxa.zhonglong.mapper.GoodsRecycleMapper;
import com.gxa.zhonglong.pojo.GoodsRecycle;
import com.gxa.zhonglong.service.GoodsRecycleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @author : 宸濯
 * Date: 2021/11/01 13:26
 * Description:
 * Version: V1.0
 */
@Service
public class GoodsRecycleServiceImpl implements GoodsRecycleService {
    @Autowired
    private GoodsRecycleMapper goodsRecycleMapper;
    @Override
    public List<Map<String, Object>> selectAll() {
        return goodsRecycleMapper.selectAll();
    }

    @Override
    public void add(GoodsRecycle goodsRecycle) throws BusinessException {
        if (!goodsRecycleMapper.add(goodsRecycle)){
            throw new BusinessException(ExceptionCode.ADD_DEFEATED);
        }

    }

    @Override
    public void update(GoodsRecycle goodsRecycle) throws BusinessException {
        if (!goodsRecycleMapper.update(goodsRecycle)){
            throw new BusinessException(ExceptionCode.UPDATE_FALSE);
        }
    }

    @Override
    public void del(List<Long> ids) throws BusinessException {
        if (!goodsRecycleMapper.del(ids)){
            throw new BusinessException(ExceptionCode.DELETE_FALSE);
        }
    }
}
